package com.qf.qfleadnewscommons.mvc;

public class ThreadLocalUtils {
    private static ThreadLocal<Long> uidTl = new ThreadLocal<>();

    /**
     * 将用户id保存到ThreadLocal线程域对象中
     * @param uid
     */
    public static void saveUid(Long uid){
        uidTl.set(uid);
    }
    /**
     * 将ThreadLocal线程域对象中的用户id删除
     */
    public static void removeUid(){
        uidTl.remove();
    }

    /**
     * 获取ThreadLocal线程域对象中的用户id
     * @return
     */
    public static Long getUid(){
        return uidTl.get();
    }
}
